package com.uzai.console.service.feign.impl;

import com.uzai.common.result.ResponseCode;
import com.uzai.console.common.UzaiRespVo;
import com.uzai.console.dto.BaseDto;
import com.uzai.console.dto.feign.uzaimanage.CdkeyMobileQueryDto;
import com.uzai.console.dto.feign.uzaimanage.SysRunlogWarningDto;
import com.uzai.console.service.feign.UzaiManageFeignService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @Auther: jianghan
 * @Date: 2022/3/30 17:26
 * @Description:
 */
@Component
public class UzaiManageFallbackFactory implements FallbackFactory<UzaiManageFeignService> {
    private static Logger logger = LoggerFactory.getLogger(UzaiManageFallbackFactory.class);
    @Override
    public UzaiManageFeignService create(Throwable throwable) {
        logger.error("--调用会员管理微服务出错，err:={}", throwable);

        return new UzaiManageFeignService() {
            @Override
            public UzaiRespVo<Object> cdkeyMobileUpdateListByCache(CdkeyMobileQueryDto cdkeyMobileQueryDto) {
                UzaiRespVo<Object> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<Object> sysRunlogWarning(SysRunlogWarningDto sysRunlogWarningDto){
                UzaiRespVo<Object> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }
        };
    }
}
